//
//  UserListVC.m
//  TheProjectName
//
//  Created by 李劲成 on 16/5/20.
//  Copyright © 2016年 sunzhichao. All rights reserved.
//

#import "UserListVC.h"

#import "FriendDetailVC.h"
@interface UserListVC ()<EMUserListViewControllerDelegate>

@end

@implementation UserListVC



- (void)viewDidLoad {
    [super viewDidLoad];
    self.delegate = self;
    self.showRefreshHeader = YES;
    self.showTableBlankView = YES;
    self.tableView.backgroundColor = [UIColor clearColor];
    self.tableView.delegate = self;
    // Do any additional setup after loading the view.
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.view.layer.contents = (id)[MotiveManager shareMotiveManager].backImage.CGImage;
    [self refresh];

}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    cell.backgroundColor = [UIColor clearColor];
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 80;
}

- (void)refresh{
    [self tableViewDidTriggerHeaderRefresh];
}


////联系人列表扩展样例
//- (id<IUserModel>)userListViewController:(EaseUsersListViewController *)userListViewController
//                           modelForBuddy:(NSString *)buddy
//{
//    //用户可以根据自己的用户体系，根据buddy设置用户昵称和头像
//    id<IUserModel> model = nil;
//    model = [[EaseUserModel alloc] initWithBuddy:buddy];
////    model.avatarURLPath = @"";//头像网络地址
////    model.nickname = @"昵称";//用户昵称
//    return model;
//}

- (void)userListViewController:(EaseUsersListViewController *)userListViewController didSelectUserModel:(id<IUserModel>)userModel{
    
    NSString *loginUsername = [[EMClient sharedClient] currentUsername];
    if (loginUsername && loginUsername.length > 0) {
        if ([loginUsername isEqualToString:userModel.buddy]) {
           
            return;
        }
    }
//#warning 联系人详情页.
    FriendDetailVC *detail = [[FriendDetailVC alloc]init];
    detail.name = userModel.buddy;
    [self.navigationController pushViewController:detail animated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
